package com.zhentao.controller;


import com.zhentao.domain.dto.AdMenu;
import com.zhentao.domain.dto.MenuDto;
import com.zhentao.result.Result;
import com.zhentao.service.TMenuService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/menu")
@Api(value = "菜单管理")
public class MenuController {

    @Resource
    private TMenuService menuService;


    //菜单列表
    @PostMapping("/list")
    public Result getMenuList(@RequestBody MenuDto dto){
        return menuService.getMenuList(dto.getMenuName());
    }

    //新增菜单
    @PostMapping("/addMenu")
    public Result addMenu(@RequestBody AdMenu adMenu){
        return this.menuService.addMenu(adMenu);
    }

    //回显菜单信息
    @GetMapping("/getMenuById/{menuId}")
    public Result getMenuById(@PathVariable("menuId") Integer menuId){
        return this.menuService.getMenuById(menuId);
    }


    //修改菜单
    @PostMapping("/upMenu")
    public Result upMenu(@RequestBody AdMenu adMenu){
        return this.menuService.upMenu(adMenu);
    }


    //删除菜单
    @GetMapping("/delMenu/{menuId}")
    public Result delMenu(@PathVariable("menuId") Integer menuId){
        return Result.OK(this.menuService.delMenuById(menuId));
    }

}
